package com.huluobo.a2302mdmdemo.demo

import android.app.AlertDialog
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier

/**
 *  Created by LC on 2025/7/21.
 */

@Composable
fun MyDialog() {
    //一般弹窗都需要一个bool的标记,来控制是否展示弹窗
    var isShow by remember {
        mutableStateOf(false)
    }

    Column {
        Button(onClick = {
            isShow = true
        }) {
            Text(text = "弹窗")
        }
    }

    if (isShow) {
        AlertDialog(onDismissRequest = {
            isShow = false
        }, confirmButton = {
            Text(text = "确认", modifier = Modifier.clickable {
                isShow = false
            })
        }, dismissButton = {
            Text(text = "取消", modifier = Modifier.clickable {
                isShow = false
            })
        }, icon = {
            Icon(imageVector = Icons.Default.Close, contentDescription = "")
        }, text = {
            Text(text = "这是一个弹窗的text")
        }, title = {
            Text(text = "这是弹窗的标题")
        })
    }
}